home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / AIncludes / OSA.a < prev    next >
Encoding:
Text File  |  1997-08-12  |  57.6 KB  |  1,831 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        OSA.a
  3. ;
  4. ;    Contains:    AppleScript Client Interfaces.
  5. ;
  6. ;    Version:    Technology:    AppleScript 1.1
  7. ;                Release:    Universal Interfaces 3.0.1
  8. ;
  9. ;    Copyright:    © 1992-1997 by Apple Computer, Inc., all rights reserved
  10. ;
  11. ;    Bugs?:        Please include the the file and version information (from above) with
  12. ;                the problem description.  Developers belonging to one of the Apple
  13. ;                developer programs can submit bug reports to:
  14. ;
  15. ;                    devsupport@apple.com
  16. ;
  17. ;
  18.     IF &TYPE('__OSA__') = 'UNDEFINED' THEN
  19. __OSA__ SET 1
  20.  
  21.     IF &TYPE('__ERRORS__') = 'UNDEFINED' THEN
  22.     include 'Errors.a'
  23.     ENDIF
  24.     IF &TYPE('__APPLEEVENTS__') = 'UNDEFINED' THEN
  25.     include 'AppleEvents.a'
  26.     ENDIF
  27.     IF &TYPE('__AEOBJECTS__') = 'UNDEFINED' THEN
  28.     include 'AEObjects.a'
  29.     ENDIF
  30.     IF &TYPE('__COMPONENTS__') = 'UNDEFINED' THEN
  31.     include 'Components.a'
  32.     ENDIF
  33.  
  34. ; **************************************************************************
  35. ;    Types and Constants
  36. ;*************************************************************************
  37.  
  38.  
  39. ;     The componenent manager type code for components that
  40. ;        support the OSA interface defined here. 
  41. ;  0x6f736120 
  42.  
  43. kOSAComponentType                EQU        'osa '
  44. ;  0x73637074 
  45.  
  46. kOSAGenericScriptingComponentSubtype EQU 'scpt'
  47. ;     Type of script document files.    
  48. ;  0x6f736173 
  49.  
  50. kOSAFileType                    EQU        'osas'
  51. ;        Suite and event code of the RecordedText event. 
  52. ;        (See OSAStartRecording, below.)
  53. ;    
  54.  
  55. ;  0x61736372 
  56.  
  57. kOSASuite                        EQU        'ascr'
  58. ;  0x72656364 
  59.  
  60. kOSARecordedText                EQU        'recd'
  61. ;  Selector returns boolean 
  62. ;  0x6d6f6469 
  63.  
  64. kOSAScriptIsModified            EQU        'modi'
  65. ;  Selector returns boolean 
  66. ;  0x63736372 
  67.  
  68. kOSAScriptIsTypeCompiledScript    EQU        'cscr'
  69. ;  Selector returns boolean 
  70. ;  0x76616c75 
  71.  
  72. kOSAScriptIsTypeScriptValue        EQU        'valu'
  73. ;  Selector returns boolean 
  74. ;  0x636e7478 
  75.  
  76. kOSAScriptIsTypeScriptContext    EQU        'cntx'
  77. ;  Selector returns a DescType which may be passed to OSACoerceToDesc 
  78. ;  0x62657374 
  79.  
  80. kOSAScriptBestType                EQU        'best'
  81. ;        This selector is used to determine whether a script has source 
  82. ;        associated with it that when given to OSAGetSource, the call will not
  83. ;        fail.  The selector returns a boolean.
  84. ;    
  85.  
  86. ;  0x67737263 
  87.  
  88. kOSACanGetSource                EQU        'gsrc'
  89.  
  90.  
  91. typeOSADialectInfo                EQU        'difo'                ;  0x6469666f   
  92. keyOSADialectName                EQU        'dnam'                ;  0x646e616d   
  93. keyOSADialectCode                EQU        'dcod'                ;  0x64636f64   
  94. keyOSADialectLangCode            EQU        'dlcd'                ;  0x646c6364   
  95. keyOSADialectScriptCode            EQU        'dscd'                ;  0x64736364   
  96. ; typedef ComponentResult                 OSAError
  97.  
  98. ;  Under the Open Scripting Architecture all error results are longs 
  99. ; typedef unsigned long                 OSAID
  100.  
  101. ;        OSAIDs allow transparent manipulation of scripts associated with
  102. ;         various scripting systems.
  103. ;    
  104.  
  105.  
  106. kOSANullScript                    EQU        0
  107. ;  No -script constant. 
  108.  
  109. kOSANullMode                    EQU        0                    ; sounds better 
  110. kOSAModeNull                    EQU        0                    ; tastes consistent 
  111. ;        Some routines take flags that control their execution.  This constant
  112. ;        declares default mode settings are used.
  113. ;    
  114.  
  115. ; **************************************************************************
  116. ;    Standard Script Errors
  117. ;**************************************************************************
  118. ;    It is recommended that scripting components use the following set of error
  119. ;    codes to signal failure when applicable.  This enables applications that
  120. ;    use the OSA API to deal with some class of script errors in a less than 
  121. ;    ad hoc manner.  Scripting components are of course encouraged to return
  122. ;    component-specific errors when these don't apply.
  123. ;*************************************************************************
  124.  
  125. ;         Dynamic errors:
  126. ;
  127. ;    These errors result from data-dependent conditions and are typically
  128. ;    signaled at runtime.
  129. ;
  130.  
  131. ;        Signaled when a value can't be coerced to the desired type. Similar
  132. ;          to errOSATypeError except results from coercion.
  133. ;    
  134.  
  135.  
  136. errOSACantCoerce                EQU        -1700
  137. ;  Signaled when an object is not found in a container 
  138.  
  139. errOSACantAccess                EQU        -1728
  140. ;        Signaled when an object cannot be set in a container.  Same as 
  141. ;          AERegistry error errAEWriteDenied.
  142. ;    
  143.  
  144.  
  145. errOSACantAssign                EQU        -10006
  146. ;        Signaled by user scripts or applications when no actual error code
  147. ;          is to be returned.  Simply means "an error has occurred".  Most useful
  148. ;          in conjunction with an error message from the application.
  149. ;    
  150.  
  151.  
  152. errOSAGeneralError                EQU        -2700
  153. ;  Signaled when there is an attempt to divide by zero 
  154.  
  155. errOSADivideByZero                EQU        -2701
  156. ;  Signaled when integer or real value is too large to be represented 
  157.  
  158. errOSANumericOverflow            EQU        -2702
  159. ;        Signaled when application can't be launched or when it is remote and
  160. ;          program linking is not enabled.
  161. ;    
  162.  
  163.  
  164. errOSACantLaunch                EQU        -2703
  165. ;  Signaled when an application can't respond to AppleEvents 
  166.  
  167. errOSAAppNotHighLevelEventAware    EQU        -2704
  168. ;  Signaled when an application's terminology resource is not readable 
  169.  
  170. errOSACorruptTerminology        EQU        -2705
  171. ;  Signaled when the runtime stack overflows 
  172.  
  173. errOSAStackOverflow                EQU        -2706
  174. ;  Signaled when a runtime internal data structure overflows 
  175.  
  176. errOSAInternalTableOverflow        EQU        -2707
  177. ;        Signaled when an intrinsic limitation is exceeded for the size of 
  178. ;          a value or data structure.
  179. ;    
  180.  
  181.  
  182. errOSADataBlockTooLarge            EQU        -2708
  183.  
  184. errOSACantGetTerminology        EQU        -2709
  185.  
  186. errOSACantCreate                EQU        -2710
  187. ;         Component-specific dynamic script errors:
  188. ;
  189. ;    The range -2720 thru -2739 is reserved for component-specific runtime errors.
  190. ;    (Note that error codes from different scripting components in this range will
  191. ;    overlap.)
  192. ;
  193.  
  194. ;         Static errors:
  195. ;
  196. ;    These errors comprise what are commonly thought of as parse and compile-
  197. ;    time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  198. ;    of these may also occur at runtime.
  199. ;
  200.  
  201.  
  202. ;  Signaled when data was not the right type and coercion is not allowed 
  203.  
  204. errOSATypeError                    EQU        -1703
  205. ;  Signaled when a message was sent to an object that didn't handle it 
  206.  
  207. OSAMessageNotUnderstood            EQU        -1708
  208. ;        Signaled when a function to be returned doesn't exist.  (Probably only
  209. ;          useful in languages with first-class functions that distinguish between
  210. ;          functions and other values (two name spaces). This is different from
  211. ;          errOSAMessageNotUnderstood, which may be signaled when the method is
  212. ;          invoked.
  213. ;    
  214.  
  215.  
  216. OSAUndefinedHandler                EQU        -1717
  217. ;  Signaled when a container can never have the requested object 
  218.  
  219. OSAIllegalAccess                EQU        -1723
  220. ;  Signaled when index was out of range. Specialization of errOSACantAccess. 
  221.  
  222. OSAIllegalIndex                    EQU        -1719
  223. ;  Signaled when a range is screwy. Specialization of errOSACantAccess. 
  224.  
  225. OSAIllegalRange                    EQU        -1720
  226. ;        Signaled when an object can never be set in a container.  Same as 
  227. ;          AERegistry error errAENotModifiable.
  228. ;    
  229.  
  230.  
  231. OSAIllegalAssign                EQU        -10003
  232. ;        Signaled when a syntax error occurs. (e.g. "Syntax error" or
  233. ;         "<this> can't go after <that>").
  234. ;    
  235.  
  236.  
  237. OSASyntaxError                    EQU        -2740
  238. ;        Signaled when another form of syntax was expected. (e.g. "expected
  239. ;          a <type> but found <this>").
  240. ;    
  241.  
  242.  
  243. OSASyntaxTypeError                EQU        -2741
  244. ;  Signaled when a name or number is too long to be parsed 
  245.  
  246. OSATokenTooLong                    EQU        -2742
  247. ;        Signaled when a parameter is missing for a function invocation.  Note
  248. ;          that in some languages, this error may occur at runtime.
  249. ;    
  250.  
  251.  
  252. OSAMissingParameter                EQU        -1701
  253. ;        Signaled when function is called with the wrong number of parameters,
  254. ;          or a parameter pattern cannot be matched.
  255. ;    
  256.  
  257.  
  258. OSAParameterMismatch            EQU        -1721
  259. ;        Signaled when a formal parameter, local variable, or instance variable
  260. ;          is specified more than once.
  261. ;    
  262.  
  263.  
  264. OSADuplicateParameter            EQU        -2750
  265. ;        Signaled when a formal parameter, local variable, or instance variable
  266. ;          is specified more than once.
  267. ;    
  268.  
  269.  
  270. OSADuplicateProperty            EQU        -2751
  271. ;        Signaled when more than one handler is defined with the same name in 
  272. ;          a scope where the language doesn't allow it.
  273. ;    
  274.  
  275.  
  276. OSADuplicateHandler                EQU        -2752
  277. ;  Signaled when a variable is accessed that has no value 
  278.  
  279. OSAUndefinedVariable            EQU        -2753
  280. ;        Signaled when a variable is declared inconsistently in the same scope,
  281. ;          such as both local and global.
  282. ;    
  283.  
  284.  
  285. OSAInconsistentDeclarations        EQU        -2754
  286. ;        Signaled when illegal control flow occurs in an application (no catcher
  287. ;          for throw, non-lexical loop exit, etc.).
  288. ;    
  289.  
  290.  
  291. OSAControlFlowError                EQU        -2755
  292. ;         Component-specific static script errors:
  293. ;
  294. ;    The range -2760 thru -2779 is reserved for component-specific parsing and
  295. ;    compile-time errors. (Note that error codes from different scripting
  296. ;    components in this range will overlap.)
  297. ;
  298.  
  299. ;         Dialect-specific script errors:
  300. ;
  301. ;    The range -2780 thru -2799 is reserved for dialect specific error codes for
  302. ;    scripting components that support dialects. (Note that error codes from
  303. ;    different scripting components in this range will overlap, as well as error
  304. ;    codes from different dialects in the same scripting component.)
  305. ;
  306.  
  307. ; **************************************************************************
  308. ;    OSA Interface Descriptions
  309. ;**************************************************************************
  310. ;    The OSA Interface is broken down into a required interface, and several
  311. ;    optional interfaces to support additional functionality.  A given scripting
  312. ;    component may choose to support only some of the optional interfaces in
  313. ;    addition to the basic interface.  The OSA Component Flags may be used to 
  314. ;    query the Component Manager to find a scripting component with a particular
  315. ;    capability, or determine if a particular scripting component supports a 
  316. ;    particular capability.
  317. ;*************************************************************************
  318.  
  319. ;  OSA Component Flags: 
  320.  
  321. kOSASupportsCompiling            EQU        $0002
  322. kOSASupportsGetSource            EQU        $0004
  323. kOSASupportsAECoercion            EQU        $0008
  324. kOSASupportsAESending            EQU        $0010
  325. kOSASupportsRecording            EQU        $0020
  326. kOSASupportsConvenience            EQU        $0040
  327. kOSASupportsDialects            EQU        $0080
  328. kOSASupportsEventHandling        EQU        $0100
  329. ;  Component Selectors: 
  330.  
  331. kOSASelectLoad                    EQU        $0001
  332. kOSASelectStore                    EQU        $0002
  333. kOSASelectExecute                EQU        $0003
  334. kOSASelectDisplay                EQU        $0004
  335. kOSASelectScriptError            EQU        $0005
  336. kOSASelectDispose                EQU        $0006
  337. kOSASelectSetScriptInfo            EQU        $0007
  338. kOSASelectGetScriptInfo            EQU        $0008
  339. kOSASelectSetActiveProc            EQU        $0009
  340. kOSASelectGetActiveProc            EQU        $000A
  341. ;  Compiling: 
  342.  
  343. kOSASelectScriptingComponentName EQU    $0102
  344. kOSASelectCompile                EQU        $0103
  345. kOSASelectCopyID                EQU        $0104
  346. ;  GetSource: 
  347.  
  348. kOSASelectGetSource                EQU        $0201
  349. ;  AECoercion: 
  350.  
  351. kOSASelectCoerceFromDesc        EQU        $0301
  352. kOSASelectCoerceToDesc            EQU        $0302
  353. ;  AESending: 
  354.  
  355. kOSASelectSetSendProc            EQU        $0401
  356. kOSASelectGetSendProc            EQU        $0402
  357. kOSASelectSetCreateProc            EQU        $0403
  358. kOSASelectGetCreateProc            EQU        $0404
  359. kOSASelectSetDefaultTarget        EQU        $0405
  360. ;  Recording: 
  361.  
  362. kOSASelectStartRecording        EQU        $0501
  363. kOSASelectStopRecording            EQU        $0502
  364. ;  Convenience: 
  365.  
  366. kOSASelectLoadExecute            EQU        $0601
  367. kOSASelectCompileExecute        EQU        $0602
  368. kOSASelectDoScript                EQU        $0603
  369. ;  Dialects: 
  370.  
  371. kOSASelectSetCurrentDialect        EQU        $0701
  372. kOSASelectGetCurrentDialect        EQU        $0702
  373. kOSASelectAvailableDialects        EQU        $0703
  374. kOSASelectGetDialectInfo        EQU        $0704
  375. kOSASelectAvailableDialectCodeList EQU    $0705
  376. ;  Event Handling: 
  377.  
  378. kOSASelectSetResumeDispatchProc    EQU        $0801
  379. kOSASelectGetResumeDispatchProc    EQU        $0802
  380. kOSASelectExecuteEvent            EQU        $0803
  381. kOSASelectDoEvent                EQU        $0804
  382. kOSASelectMakeContext            EQU        $0805
  383.  
  384. ;  scripting component specific selectors are added beginning with this value  
  385.  
  386. kOSASelectComponentSpecificStart EQU    $1001
  387.  
  388. ;         Mode Flags:
  389. ;
  390. ;    Warning: These should not conflict with the AESend mode flags in
  391. ;    AppleEvents.h, because we may want to use them as OSA mode flags too.
  392. ;
  393.  
  394.  
  395. ;        This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  396. ;          instruct the scripting component to not retain the "source" of an
  397. ;          expression.  This will cause the OSAGetSource call to return the error
  398. ;          errOSASourceNotAvailable if used.  However, some scripting components
  399. ;          may not retain the source anyway.  This is mainly used when either space
  400. ;          efficiency is desired, or a script is to be "locked" so that its
  401. ;          implementation may not be viewed.
  402. ;    
  403.  
  404.  
  405. kOSAModePreventGetSource        EQU        $00000001
  406. ;        These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  407. ;          OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  408. ;          indicate whether or not the script may interact with the user, switch
  409. ;          layer or reconnect if necessary.  Any AppleEvents will be sent with the
  410. ;          corresponding AESend mode supplied.
  411. ;    
  412.  
  413.  
  414. kOSAModeNeverInteract            EQU        $00000010
  415. kOSAModeCanInteract                EQU        $00000020
  416. kOSAModeAlwaysInteract            EQU        $00000030
  417. kOSAModeDontReconnect            EQU        $00000080
  418. ;        This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  419. ;          OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  420. ;          indicate whether or not AppleEvents should be sent with the
  421. ;          kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  422. ;          opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  423. ;          provide a more convenient default, i.e. not supplying any mode
  424. ;          (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  425. ;          the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  426. ;          without kAECanSwitchLayer.
  427. ;    
  428.  
  429.  
  430. kOSAModeCantSwitchLayer            EQU        $00000040
  431. ;        This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  432. ;          OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  433. ;          indicate whether or not AppleEvents should be sent with the kAEDontRecord
  434. ;          mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  435. ;          the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  436. ;          default, i.e. not supplying any mode (kOSAModeNull) means to send events
  437. ;          with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  438. ;          cause AESend to be called without kAEDontRecord.
  439. ;    
  440.  
  441.  
  442. kOSAModeDoRecord                EQU        $00001000
  443. ;        This is a mode flag for OSACompile that indicates that a context should
  444. ;          be created as the result of compilation. All handler definitions are
  445. ;          inserted into the new context, and variables are initialized by
  446. ;          evaluating their initial values in a null context (i.e. they must be
  447. ;          constant expressions).
  448. ;    
  449.  
  450.  
  451. kOSAModeCompileIntoContext        EQU        $00000002
  452. ;        This is a mode flag for OSACompile that indicates that the previous
  453. ;          script ID (input to OSACompile) should be augmented with any new
  454. ;          definitions in the sourceData rather than replaced with a new script.
  455. ;          This means that the previous script ID must designate a context.
  456. ;          The presence of this flag causes the kOSAModeCompileIntoContext flag
  457. ;          to be implicitly used, causing any new definitions to be initialized
  458. ;          in a null context.
  459. ;    
  460.  
  461.  
  462. kOSAModeAugmentContext            EQU        $00000004
  463. ;        This mode flag may be passed to OSADisplay or OSADoScript to indicate
  464. ;          that output only need be human-readable, not re-compilable by OSACompile.
  465. ;          If used, output may be arbitrarily "beautified", e.g. quotes may be left
  466. ;          off of string values, long lists may have elipses, etc.
  467. ;    
  468.  
  469.  
  470. kOSAModeDisplayForHumans        EQU        $00000008
  471. ;        This mode flag may be passed to OSAStore in the case where the scriptID
  472. ;          is a context.  This causes the context to be saved, but not the context's
  473. ;          parent context.  When the stored context is loaded back in, the parent
  474. ;          will be kOSANullScript.
  475. ;    
  476.  
  477.  
  478. kOSAModeDontStoreParent            EQU        $00010000
  479. ;        This mode flag may be passed to OSAExecuteEvent to cause the event to
  480. ;          be dispatched to the direct object of the event. The direct object (or
  481. ;          subject attribute if the direct object is a non-object specifier) will
  482. ;          be resolved, and the resulting script object will be the recipient of
  483. ;          the message. The context argument to OSAExecuteEvent will serve as the
  484. ;          root of the lookup/resolution process.
  485. ;    
  486.  
  487.  
  488. kOSAModeDispatchToDirectObject    EQU        $00020000
  489. ;        This mode flag may be passed to OSAExecuteEvent to indicate that
  490. ;          components do not have to get the data of object specifier arguments.
  491. ;    
  492.  
  493.  
  494. kOSAModeDontGetDataForArguments    EQU        $00040000
  495. ; **************************************************************************
  496. ;    OSA Basic Scripting Interface
  497. ;**************************************************************************
  498. ;    Scripting components must at least support the Basic Scripting interface.
  499. ;*************************************************************************
  500.  
  501. ;         Loading and Storing Scripts:
  502. ;
  503. ;    These routines allow scripts to be loaded and stored in their internal
  504. ;    (possibly compiled, non-text) representation.
  505. ;
  506.  
  507.  
  508. ;  Resource type for scripts 
  509.  
  510. kOSAScriptResourceType            EQU        'scpt'
  511. ;        Default type given to OSAStore which creates "generic" loadable script
  512. ;          data descriptors.
  513. ;    
  514.  
  515.  
  516. typeOSAGenericStorage            EQU        'scpt'
  517. ;
  518. ; pascal OSAError OSALoad(ComponentInstance scriptingComponent, const AEDesc *scriptData, long modeFlags, OSAID *resultingScriptID)
  519. ;
  520.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  521.         Macro
  522.         _OSALoad
  523.             move.l              #$000C0001,-(sp)
  524.             moveq               #0,D0
  525.             dc.w                $A82A
  526.         EndM
  527.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  528.         IMPORT_CFM_FUNCTION OSALoad
  529.     ENDIF
  530.  
  531. ;        OSAComponentFunctionInline(kOSASelectLoad, 12);
  532. ;    
  533. ;        Errors:
  534. ;            badComponentInstance        invalid scripting component instance
  535. ;            errOSASystemError
  536. ;            errOSABadStorageType:        scriptData not for this scripting component
  537. ;            errOSACorruptData:            data seems to be corrupt
  538. ;            errOSADataFormatObsolete    script data format is no longer supported
  539. ;            errOSADataFormatTooNew        script data format is from a newer version
  540. ;        
  541. ;        ModeFlags:
  542. ;            kOSAModePreventGetSource
  543. ;    
  544.  
  545. ;
  546. ; pascal OSAError OSAStore(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, long modeFlags, AEDesc *resultingScriptData)
  547. ;
  548.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  549.         Macro
  550.         _OSAStore
  551.             move.l              #$00100002,-(sp)
  552.             moveq               #0,D0
  553.             dc.w                $A82A
  554.         EndM
  555.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  556.         IMPORT_CFM_FUNCTION OSAStore
  557.     ENDIF
  558.  
  559. ;        OSAComponentFunctionInline(kOSASelectStore, 16);
  560. ;    
  561. ;        Errors:
  562. ;            badComponentInstance    invalid scripting component instance
  563. ;            errOSASystemError
  564. ;            errOSAInvalidID
  565. ;            errOSABadStorageType:    desiredType not for this scripting component
  566. ;        
  567. ;        ModeFlags:
  568. ;            kOSAModePreventGetSource
  569. ;            kOSAModeDontStoreParent
  570. ;    
  571.  
  572. ;  Executing Scripts: 
  573. ;
  574. ; pascal OSAError OSAExecute(ComponentInstance scriptingComponent, OSAID compiledScriptID, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  575. ;
  576.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  577.         Macro
  578.         _OSAExecute
  579.             move.l              #$00100003,-(sp)
  580.             moveq               #0,D0
  581.             dc.w                $A82A
  582.         EndM
  583.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  584.         IMPORT_CFM_FUNCTION OSAExecute
  585.     ENDIF
  586.  
  587. ;        OSAComponentFunctionInline(kOSASelectExecute, 16);
  588. ;        This call runs a script.  The contextID represents the environment
  589. ;        with which global variables in the script are resolved.  The constant
  590. ;        kOSANullScript may be used for the contextID if the application wishes
  591. ;        to not deal with context directly (a default one is associated with each
  592. ;        scripting component instance).  The resultingScriptValueID is the 
  593. ;        result of evaluation, and contains a value which may be displayed using
  594. ;        the OSAGetSource call.  The modeFlags convey scripting component
  595. ;        specific information.
  596. ;    
  597. ;        Errors:
  598. ;            badComponentInstance    invalid scripting component instance
  599. ;            errOSASystemError
  600. ;            errOSAInvalidID
  601. ;            errOSAScriptError:        the executing script got an error
  602. ;    
  603. ;        ModeFlags:
  604. ;            kOSAModeNeverInteract
  605. ;            kOSAModeCanInteract
  606. ;            kOSAModeAlwaysInteract
  607. ;            kOSAModeCantSwitchLayer
  608. ;            kOSAModeDontReconnect
  609. ;            kOSAModeDoRecord
  610. ;    
  611.  
  612. ;  Displaying results: 
  613. ;
  614. ; pascal OSAError OSADisplay(ComponentInstance scriptingComponent, OSAID scriptValueID, DescType desiredType, long modeFlags, AEDesc *resultingText)
  615. ;
  616.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  617.         Macro
  618.         _OSADisplay
  619.             move.l              #$00100004,-(sp)
  620.             moveq               #0,D0
  621.             dc.w                $A82A
  622.         EndM
  623.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  624.         IMPORT_CFM_FUNCTION OSADisplay
  625.     ENDIF
  626.  
  627. ;        OSAComponentFunctionInline(kOSASelectDisplay, 16);
  628. ;        This call is used to convert results (script value IDs) into displayable
  629. ;        text. The desiredType should be at least typeChar, and modeFlags are
  630. ;        scripting system specific flags to control the formatting of the
  631. ;        resulting text. This call differs from OSAGetSource in that (1) it
  632. ;        always produces at least typeChar, (2) is only works on script values,
  633. ;        (3) it may display it's output in non-compilable form (e.g. without
  634. ;        string quotes, elipses inserted in long and/or circular lists, etc.) and
  635. ;        (4) it is required by the basic scripting interface.
  636. ;    
  637. ;        Errors:
  638. ;            badComponentInstance    invalid scripting component instance
  639. ;            errOSASystemError
  640. ;            errOSAInvalidID
  641. ;            errAECoercionFail:        desiredType not supported by scripting component
  642. ;    
  643. ;        ModeFlags:
  644. ;            kOSAModeDisplayForHumans
  645. ;    
  646.  
  647. ;  Getting Error Information: 
  648. ;
  649. ; pascal OSAError OSAScriptError(ComponentInstance scriptingComponent, OSType selector, DescType desiredType, AEDesc *resultingErrorDescription)
  650. ;
  651.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  652.         Macro
  653.         _OSAScriptError
  654.             move.l              #$000C0005,-(sp)
  655.             moveq               #0,D0
  656.             dc.w                $A82A
  657.         EndM
  658.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  659.         IMPORT_CFM_FUNCTION OSAScriptError
  660.     ENDIF
  661.  
  662. ;        OSAComponentFunctionInline(kOSASelectScriptError, 12);
  663. ;        Whenever script execution returns errOSAExecutionError, this routine
  664. ;        may be used to get information about that error.  The selector describes
  665. ;        the type of information desired about the error (various selectors are
  666. ;        listed below).  The desiredType indicates the data type of the result
  667. ;        desired for that selector.
  668. ;    
  669. ;        Errors:
  670. ;            badComponentInstance    invalid scripting component instance
  671. ;            errOSASystemError
  672. ;            errOSABadSelector:        selector not supported by scripting component
  673. ;            errAECoercionFail:        desiredType not supported by scripting component
  674. ;    
  675.  
  676. ;  OSAScriptError selectors: 
  677. ;        This selector is used to determine the error number of a script error.
  678. ;        These error numbers may be either system error numbers, or error numbers
  679. ;        that are scripting component specific.
  680. ;        Required desiredTypes:    
  681. ;              typeShortInteger
  682. ;    
  683.  
  684.  
  685. kOSAErrorNumber                    EQU        'errn'
  686. ;        This selector is used to determine the full error message associated
  687. ;        with the error number.  It should include the name of the application
  688. ;        which caused the error, as well as the specific error that occurred.
  689. ;        This selector is sufficient for simple error reporting (but see
  690. ;        kOSAErrorBriefMessage, below).
  691. ;        Required desiredTypes:
  692. ;            typeChar                    error message string
  693. ;    
  694.  
  695.  
  696. kOSAErrorMessage                EQU        'errs'
  697. ;        This selector is used to determine a brief error message associated with
  698. ;        the error number.  This message and should not mention the name of the
  699. ;        application which caused the error, any partial results or offending
  700. ;        object (see kOSAErrorApp, kOSAErrorPartialResult and
  701. ;        kOSAErrorOffendingObject, below).
  702. ;        Required desiredTypes:
  703. ;              typeChar                    brief error message string
  704. ;    
  705.  
  706. ;   0x65727262  
  707.  
  708. kOSAErrorBriefMessage            EQU        'errb'
  709. ;        This selector is used to determine which application actually got the
  710. ;        error (if it was the result of an AESend), or the current application
  711. ;        if ....
  712. ;        Required desiredTypes:
  713. ;              typeProcessSerialNumber        PSN of the errant application
  714. ;              typeChar                    name of the errant application
  715. ;    
  716.  
  717. ;   0x65726170  
  718.  
  719. kOSAErrorApp                    EQU        'erap'
  720. ;        This selector is used to determine any partial result returned by an 
  721. ;        operation. If an AESend call failed, but a partial result was returned,
  722. ;        then the partial result may be returned as an AEDesc.
  723. ;        Required desiredTypes:
  724. ;              typeBest                    AEDesc of any partial result
  725. ;    
  726.  
  727. ;   0x70746c72   
  728.  
  729. kOSAErrorPartialResult            EQU        'ptlr'
  730. ;        This selector is used to determine any object which caused the error
  731. ;        that may have been indicated by an application.  The result is an 
  732. ;        AEDesc.
  733. ;        Required desiredTypes:
  734. ;              typeBest                    AEDesc of any offending object
  735. ;    
  736.  
  737. ;   0x65726f62   
  738.  
  739. kOSAErrorOffendingObject        EQU        'erob'
  740. ;        This selector is used to determine the type expected by a coercion 
  741. ;        operation if a type error occurred.
  742. ;    
  743.  
  744. ;   0x65727274   
  745.  
  746. kOSAErrorExpectedType            EQU        'errt'
  747. ;        This selector is used to determine the source text range (start and 
  748. ;        end positions) of where the error occurred.
  749. ;        Required desiredTypes:
  750. ;              typeOSAErrorRange
  751. ;    
  752.  
  753. ;   0x65726e67  
  754.  
  755. kOSAErrorRange                    EQU        'erng'
  756. ;        An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  757. ;        of type short.
  758. ;    
  759.  
  760. ;   0x65726e67   
  761.  
  762. typeOSAErrorRange                EQU        'erng'
  763. ;  Field of a typeOSAErrorRange record of typeShortInteger 
  764. ;   0x73726373    
  765.  
  766. keyOSASourceStart                EQU        'srcs'
  767. ;  Field of a typeOSAErrorRange record of typeShortInteger 
  768. ;   0x73726365   
  769.  
  770. keyOSASourceEnd                    EQU        'srce'
  771. ;  Disposing Script IDs: 
  772. ;
  773. ; pascal OSAError OSADispose(ComponentInstance scriptingComponent, OSAID scriptID)
  774. ;
  775.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  776.         Macro
  777.         _OSADispose
  778.             move.l              #$00040006,-(sp)
  779.             moveq               #0,D0
  780.             dc.w                $A82A
  781.         EndM
  782.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  783.         IMPORT_CFM_FUNCTION OSADispose
  784.     ENDIF
  785.  
  786. ;        OSAComponentFunctionInline(kOSASelectDispose, 4);
  787. ;        Disposes a script or context.
  788. ;    
  789. ;        Errors:
  790. ;            badComponentInstance    invalid scripting component instance
  791. ;            errOSASystemError
  792. ;            errOSAInvalidID
  793. ;    
  794.  
  795. ;  Getting and Setting Script Information: 
  796. ;
  797. ; pascal OSAError OSASetScriptInfo(ComponentInstance scriptingComponent, OSAID scriptID, OSType selector, long value)
  798. ;
  799.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  800.         Macro
  801.         _OSASetScriptInfo
  802.             move.l              #$000C0007,-(sp)
  803.             moveq               #0,D0
  804.             dc.w                $A82A
  805.         EndM
  806.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  807.         IMPORT_CFM_FUNCTION OSASetScriptInfo
  808.     ENDIF
  809.  
  810. ;        OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  811. ;    
  812. ;        Errors:
  813. ;            badComponentInstance    invalid scripting component instance
  814. ;            errOSASystemError
  815. ;            errOSAInvalidID
  816. ;            errOSABadSelector:        selector not supported by scripting component
  817. ;                                    or selector not for this scriptID
  818. ;    
  819.  
  820. ;
  821. ; pascal OSAError OSAGetScriptInfo(ComponentInstance scriptingComponent, OSAID scriptID, OSType selector, long *result)
  822. ;
  823.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  824.         Macro
  825.         _OSAGetScriptInfo
  826.             move.l              #$000C0008,-(sp)
  827.             moveq               #0,D0
  828.             dc.w                $A82A
  829.         EndM
  830.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  831.         IMPORT_CFM_FUNCTION OSAGetScriptInfo
  832.     ENDIF
  833.  
  834. ;        OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  835. ;    
  836. ;        Errors:
  837. ;            badComponentInstance    invalid scripting component instance
  838. ;            errOSASystemError
  839. ;            errOSAInvalidID
  840. ;            errOSABadSelector:        selector not supported by scripting component
  841. ;                                    or selector not for this scriptID
  842. ;    
  843.  
  844. ;  Manipulating the ActiveProc:
  845. ;
  846. ;    Scripting systems will supply default values for these procedures if they
  847. ;    are not set by the client:
  848. ;
  849.  
  850. ;
  851. ; pascal OSAError OSASetActiveProc(ComponentInstance scriptingComponent, OSAActiveUPP activeProc, long refCon)
  852. ;
  853.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  854.         Macro
  855.         _OSASetActiveProc
  856.             move.l              #$00080009,-(sp)
  857.             moveq               #0,D0
  858.             dc.w                $A82A
  859.         EndM
  860.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  861.         IMPORT_CFM_FUNCTION OSASetActiveProc
  862.     ENDIF
  863.  
  864. ;        OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  865. ;        If activeProc is nil, the default activeProc is used.
  866. ;    
  867. ;        Errors:
  868. ;            badComponentInstance    invalid scripting component instance
  869. ;            errOSASystemError
  870. ;    
  871.  
  872. ;
  873. ; pascal OSAError OSAGetActiveProc(ComponentInstance scriptingComponent, OSAActiveUPP *activeProc, long *refCon)
  874. ;
  875.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  876.         Macro
  877.         _OSAGetActiveProc
  878.             move.l              #$0008000A,-(sp)
  879.             moveq               #0,D0
  880.             dc.w                $A82A
  881.         EndM
  882.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  883.         IMPORT_CFM_FUNCTION OSAGetActiveProc
  884.     ENDIF
  885.  
  886. ;        OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  887. ;    
  888. ;        Errors:
  889. ;            badComponentInstance    invalid scripting component instance
  890. ;            errOSASystemError
  891. ;    
  892.  
  893. ; **************************************************************************
  894. ;    OSA Optional Compiling Interface
  895. ;**************************************************************************
  896. ;    Scripting components that support the Compiling interface have the 
  897. ;    kOSASupportsCompiling bit set in it's ComponentDescription.
  898. ;*************************************************************************
  899.  
  900. ;
  901. ; pascal OSAError OSAScriptingComponentName(ComponentInstance scriptingComponent, AEDesc *resultingScriptingComponentName)
  902. ;
  903.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  904.         Macro
  905.         _OSAScriptingComponentName
  906.             move.l              #$00040102,-(sp)
  907.             moveq               #0,D0
  908.             dc.w                $A82A
  909.         EndM
  910.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  911.         IMPORT_CFM_FUNCTION OSAScriptingComponentName
  912.     ENDIF
  913.  
  914. ;        OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  915. ;        Given a scripting component, this routine returns the name of that
  916. ;        scripting component in a type that is coercable to text (typeChar).
  917. ;        The generic scripting component returns the name of the default
  918. ;        scripting component.  This name should be sufficient to convey to the
  919. ;        user the kind of script (syntax) he is expected to write.
  920. ;    
  921. ;        Errors:
  922. ;            badComponentInstance    invalid scripting component instance
  923. ;            errOSASystemError
  924. ;    
  925.  
  926. ;
  927. ; pascal OSAError OSACompile(ComponentInstance scriptingComponent, const AEDesc *sourceData, long modeFlags, OSAID *previousAndResultingScriptID)
  928. ;
  929.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  930.         Macro
  931.         _OSACompile
  932.             move.l              #$000C0103,-(sp)
  933.             moveq               #0,D0
  934.             dc.w                $A82A
  935.         EndM
  936.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  937.         IMPORT_CFM_FUNCTION OSACompile
  938.     ENDIF
  939.  
  940. ;        OSAComponentFunctionInline(kOSASelectCompile, 12);
  941. ;        Coerces input desc (possibly text) into a script's internal format.
  942. ;        Once compiled, the script is ready to run.  The modeFlags convey
  943. ;        scripting component specific information.  The previous script ID
  944. ;        (result parameter) is made to refer to the newly compiled script,
  945. ;        unless it was originally kOSANullScript.  In this case a new script
  946. ;        ID is created and used.
  947. ;    
  948. ;        Errors:
  949. ;            badComponentInstance    invalid scripting component instance
  950. ;            errOSASystemError
  951. ;            errAECoercionFail:        sourceData is not compilable
  952. ;            errOSAScriptError:        sourceData was a bad script (syntax error)
  953. ;            errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  954. ;                                    valid on input
  955. ;    
  956. ;        ModeFlags:
  957. ;            kOSAModePreventGetSource
  958. ;            kOSAModeCompileIntoContext
  959. ;            kOSAModeAugmentContext
  960. ;            kOSAModeNeverInteract
  961. ;            kOSAModeCanInteract
  962. ;            kOSAModeAlwaysInteract
  963. ;            kOSAModeCantSwitchLayer
  964. ;            kOSAModeDontReconnect
  965. ;            kOSAModeDoRecord
  966. ;    
  967.  
  968. ;
  969. ; pascal OSAError OSACopyID(ComponentInstance scriptingComponent, OSAID fromID, OSAID *toID)
  970. ;
  971.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  972.         Macro
  973.         _OSACopyID
  974.             move.l              #$00080104,-(sp)
  975.             moveq               #0,D0
  976.             dc.w                $A82A
  977.         EndM
  978.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  979.         IMPORT_CFM_FUNCTION OSACopyID
  980.     ENDIF
  981.  
  982. ;        OSAComponentFunctionInline(kOSASelectCopyID, 8);
  983. ;        If toID is a reference to kOSANullScript then it is updated to have a
  984. ;        new scriptID value.  This call can be used to perform undo or revert
  985. ;        operations on scripts. 
  986. ;    
  987. ;        Errors:
  988. ;            badComponentInstance    invalid scripting component instance
  989. ;            errOSASystemError
  990. ;            errOSAInvalidID
  991. ;    
  992.  
  993. ; **************************************************************************
  994. ;    OSA Optional GetSource Interface
  995. ;**************************************************************************
  996. ;    Scripting components that support the GetSource interface have the 
  997. ;    kOSASupportsGetSource bit set in it's ComponentDescription.
  998. ;*************************************************************************
  999.  
  1000. ;
  1001. ; pascal OSAError OSAGetSource(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, AEDesc *resultingSourceData)
  1002. ;
  1003.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1004.         Macro
  1005.         _OSAGetSource
  1006.             move.l              #$000C0201,-(sp)
  1007.             moveq               #0,D0
  1008.             dc.w                $A82A
  1009.         EndM
  1010.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1011.         IMPORT_CFM_FUNCTION OSAGetSource
  1012.     ENDIF
  1013.  
  1014. ;        OSAComponentFunctionInline(kOSASelectGetSource, 12);
  1015. ;        This routine causes a compiled script to be output in a form (possibly
  1016. ;        text) such that it is suitable to be passed back to OSACompile.
  1017. ;
  1018. ;        Errors:
  1019. ;            badComponentInstance    invalid scripting component instance
  1020. ;            errOSASystemError
  1021. ;            errOSAInvalidID
  1022. ;            errOSASourceNotAvailable    can't get source for this scriptID
  1023. ;    
  1024.  
  1025. ; **************************************************************************
  1026. ;    OSA Optional AECoercion Interface
  1027. ;**************************************************************************
  1028. ;    Scripting components that support the AECoercion interface have the 
  1029. ;    kOSASupportsAECoercion bit set in it's ComponentDescription.
  1030. ;*************************************************************************
  1031.  
  1032. ;
  1033. ; pascal OSAError OSACoerceFromDesc(ComponentInstance scriptingComponent, const AEDesc *scriptData, long modeFlags, OSAID *resultingScriptID)
  1034. ;
  1035.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1036.         Macro
  1037.         _OSACoerceFromDesc
  1038.             move.l              #$000C0301,-(sp)
  1039.             moveq               #0,D0
  1040.             dc.w                $A82A
  1041.         EndM
  1042.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1043.         IMPORT_CFM_FUNCTION OSACoerceFromDesc
  1044.     ENDIF
  1045.  
  1046. ;        OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  1047. ;        This routine causes script data to be coerced into a script value.
  1048. ;        If the scriptData is an AppleEvent, then the resultingScriptID is a
  1049. ;        compiled script ID (mode flags for OSACompile may be used in this case).
  1050. ;        Other scriptData descriptors create script value IDs.
  1051. ;    
  1052. ;        Errors:
  1053. ;            badComponentInstance    invalid scripting component instance
  1054. ;            errOSASystemError
  1055. ;    
  1056. ;        ModeFlags:
  1057. ;            kOSAModePreventGetSource
  1058. ;            kOSAModeCompileIntoContext
  1059. ;            kOSAModeNeverInteract
  1060. ;            kOSAModeCanInteract
  1061. ;            kOSAModeAlwaysInteract
  1062. ;            kOSAModeCantSwitchLayer
  1063. ;            kOSAModeDontReconnect
  1064. ;            kOSAModeDoRecord
  1065. ;    
  1066.  
  1067. ;
  1068. ; pascal OSAError OSACoerceToDesc(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, long modeFlags, AEDesc *result)
  1069. ;
  1070.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1071.         Macro
  1072.         _OSACoerceToDesc
  1073.             move.l              #$00100302,-(sp)
  1074.             moveq               #0,D0
  1075.             dc.w                $A82A
  1076.         EndM
  1077.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1078.         IMPORT_CFM_FUNCTION OSACoerceToDesc
  1079.     ENDIF
  1080.  
  1081. ;        OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  1082. ;        This routine causes a script value to be coerced into any desired form.
  1083. ;        If the scriptID denotes a compiled script, then it may be coerced to 
  1084. ;        typeAppleEvent.
  1085. ;    
  1086. ;        Errors:
  1087. ;            badComponentInstance    invalid scripting component instance
  1088. ;            errOSASystemError
  1089. ;            errOSAInvalidID
  1090. ;    
  1091.  
  1092. ; **************************************************************************
  1093. ;    OSA Optional AESending Interface
  1094. ;**************************************************************************
  1095. ;    Scripting components that support the AESending interface have the 
  1096. ;    kOSASupportsAESending bit set in it's ComponentDescription.
  1097. ;*************************************************************************
  1098.  
  1099. ;    Scripting systems will supply default values for these procedures if they
  1100. ;    are not set by the client:
  1101. ;
  1102.  
  1103. ;
  1104. ; pascal OSAError OSASetSendProc(ComponentInstance scriptingComponent, OSASendUPP sendProc, long refCon)
  1105. ;
  1106.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1107.         Macro
  1108.         _OSASetSendProc
  1109.             move.l              #$00080401,-(sp)
  1110.             moveq               #0,D0
  1111.             dc.w                $A82A
  1112.         EndM
  1113.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1114.         IMPORT_CFM_FUNCTION OSASetSendProc
  1115.     ENDIF
  1116.  
  1117. ;        OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1118. ;        If sendProc is nil, the default sendProc is used.
  1119. ;    
  1120. ;        Errors:
  1121. ;            badComponentInstance    invalid scripting component instance
  1122. ;            errOSASystemError
  1123. ;    
  1124.  
  1125. ;
  1126. ; pascal OSAError OSAGetSendProc(ComponentInstance scriptingComponent, OSASendUPP *sendProc, long *refCon)
  1127. ;
  1128.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1129.         Macro
  1130.         _OSAGetSendProc
  1131.             move.l              #$00080402,-(sp)
  1132.             moveq               #0,D0
  1133.             dc.w                $A82A
  1134.         EndM
  1135.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1136.         IMPORT_CFM_FUNCTION OSAGetSendProc
  1137.     ENDIF
  1138.  
  1139. ;        OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1140. ;    
  1141. ;        Errors:
  1142. ;            badComponentInstance    invalid scripting component instance
  1143. ;            errOSASystemError
  1144. ;    
  1145.  
  1146. ;
  1147. ; pascal OSAError OSASetCreateProc(ComponentInstance scriptingComponent, OSACreateAppleEventUPP createProc, long refCon)
  1148. ;
  1149.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1150.         Macro
  1151.         _OSASetCreateProc
  1152.             move.l              #$00080403,-(sp)
  1153.             moveq               #0,D0
  1154.             dc.w                $A82A
  1155.         EndM
  1156.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1157.         IMPORT_CFM_FUNCTION OSASetCreateProc
  1158.     ENDIF
  1159.  
  1160. ;        OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1161. ;        If createProc is nil, the default createProc is used.
  1162. ;    
  1163. ;        Errors:
  1164. ;            badComponentInstance    invalid scripting component instance
  1165. ;            errOSASystemError
  1166. ;    
  1167.  
  1168. ;
  1169. ; pascal OSAError OSAGetCreateProc(ComponentInstance scriptingComponent, OSACreateAppleEventUPP *createProc, long *refCon)
  1170. ;
  1171.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1172.         Macro
  1173.         _OSAGetCreateProc
  1174.             move.l              #$00080404,-(sp)
  1175.             moveq               #0,D0
  1176.             dc.w                $A82A
  1177.         EndM
  1178.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1179.         IMPORT_CFM_FUNCTION OSAGetCreateProc
  1180.     ENDIF
  1181.  
  1182. ;        OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1183. ;    
  1184. ;        Errors:
  1185. ;            badComponentInstance    invalid scripting component instance
  1186. ;            errOSASystemError
  1187. ;    
  1188.  
  1189. ;
  1190. ; pascal OSAError OSASetDefaultTarget(ComponentInstance scriptingComponent, const AEAddressDesc *target)
  1191. ;
  1192.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1193.         Macro
  1194.         _OSASetDefaultTarget
  1195.             move.l              #$00040405,-(sp)
  1196.             moveq               #0,D0
  1197.             dc.w                $A82A
  1198.         EndM
  1199.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1200.         IMPORT_CFM_FUNCTION OSASetDefaultTarget
  1201.     ENDIF
  1202.  
  1203. ;        OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1204. ;        This routine sets the default target application for AE sending.
  1205. ;        It also establishes the default target from which terminologies come.
  1206. ;        It is effectively like having an AppleScript "tell" statement around
  1207. ;        the entire program.  If this routine is not called, or if the target 
  1208. ;        is a null AEDesc, then the current application is the default target.
  1209. ;    
  1210. ;        Errors:
  1211. ;            badComponentInstance    invalid scripting component instance
  1212. ;            errOSASystemError
  1213. ;    
  1214.  
  1215. ; **************************************************************************
  1216. ;    OSA Optional Recording Interface
  1217. ;**************************************************************************
  1218. ;    Scripting components that support the Recording interface have the 
  1219. ;    kOSASupportsRecording bit set in it's ComponentDescription.
  1220. ;*************************************************************************
  1221.  
  1222. ;
  1223. ; pascal OSAError OSAStartRecording(ComponentInstance scriptingComponent, OSAID *compiledScriptToModifyID)
  1224. ;
  1225.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1226.         Macro
  1227.         _OSAStartRecording
  1228.             move.l              #$00040501,-(sp)
  1229.             moveq               #0,D0
  1230.             dc.w                $A82A
  1231.         EndM
  1232.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1233.         IMPORT_CFM_FUNCTION OSAStartRecording
  1234.     ENDIF
  1235.  
  1236. ;        OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1237. ;        Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1238. ;        new script ID is created and returned.  If the current application has
  1239. ;        a handler for the kOSARecordedText event, then kOSARecordedText events
  1240. ;        are sent to the application containing the text of each AppleEvent 
  1241. ;        recorded.
  1242. ;    
  1243. ;        Errors:
  1244. ;            badComponentInstance    invalid scripting component instance
  1245. ;            errOSASystemError
  1246. ;            errOSAInvalidID
  1247. ;            errOSARecordingIsAlreadyOn
  1248. ;    
  1249.  
  1250. ;
  1251. ; pascal OSAError OSAStopRecording(ComponentInstance scriptingComponent, OSAID compiledScriptID)
  1252. ;
  1253.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1254.         Macro
  1255.         _OSAStopRecording
  1256.             move.l              #$00040502,-(sp)
  1257.             moveq               #0,D0
  1258.             dc.w                $A82A
  1259.         EndM
  1260.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1261.         IMPORT_CFM_FUNCTION OSAStopRecording
  1262.     ENDIF
  1263.  
  1264. ;        OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1265. ;        If compiledScriptID is not being recorded into or recording is not
  1266. ;        currently on, no error is returned.
  1267. ;    
  1268. ;        Errors:
  1269. ;            badComponentInstance    invalid scripting component instance
  1270. ;            errOSASystemError
  1271. ;            errOSAInvalidID
  1272. ;    
  1273.  
  1274. ; **************************************************************************
  1275. ;    OSA Optional Convenience Interface
  1276. ;**************************************************************************
  1277. ;    Scripting components that support the Convenience interface have the 
  1278. ;    kOSASupportsConvenience bit set in it's ComponentDescription.
  1279. ;*************************************************************************
  1280.  
  1281. ;
  1282. ; pascal OSAError OSALoadExecute(ComponentInstance scriptingComponent, const AEDesc *scriptData, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1283. ;
  1284.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1285.         Macro
  1286.         _OSALoadExecute
  1287.             move.l              #$00100601,-(sp)
  1288.             moveq               #0,D0
  1289.             dc.w                $A82A
  1290.         EndM
  1291.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1292.         IMPORT_CFM_FUNCTION OSALoadExecute
  1293.     ENDIF
  1294.  
  1295. ;        OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1296. ;        This routine is effectively equivalent to calling OSALoad followed by
  1297. ;        OSAExecute.  After execution, the compiled source is disposed.  Only the
  1298. ;        resulting value ID is retained.
  1299. ;    
  1300. ;        Errors:
  1301. ;            badComponentInstance        invalid scripting component instance
  1302. ;            errOSASystemError
  1303. ;            errOSABadStorageType:        scriptData not for this scripting component
  1304. ;            errOSACorruptData:            data seems to be corrupt
  1305. ;            errOSADataFormatObsolete    script data format is no longer supported
  1306. ;            errOSADataFormatTooNew        script data format is from a newer version
  1307. ;            errOSAInvalidID
  1308. ;            errOSAScriptError:            the executing script got an error
  1309. ;    
  1310. ;        ModeFlags:
  1311. ;            kOSAModeNeverInteract
  1312. ;            kOSAModeCanInteract
  1313. ;            kOSAModeAlwaysInteract
  1314. ;            kOSAModeCantSwitchLayer
  1315. ;            kOSAModeDontReconnect
  1316. ;            kOSAModeDoRecord
  1317. ;    
  1318.  
  1319. ;
  1320. ; pascal OSAError OSACompileExecute(ComponentInstance scriptingComponent, const AEDesc *sourceData, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1321. ;
  1322.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1323.         Macro
  1324.         _OSACompileExecute
  1325.             move.l              #$00100602,-(sp)
  1326.             moveq               #0,D0
  1327.             dc.w                $A82A
  1328.         EndM
  1329.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1330.         IMPORT_CFM_FUNCTION OSACompileExecute
  1331.     ENDIF
  1332.  
  1333. ;        OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1334. ;        This routine is effectively equivalent to calling OSACompile followed by
  1335. ;        OSAExecute.  After execution, the compiled source is disposed.  Only the
  1336. ;        resulting value ID is retained.
  1337. ;    
  1338. ;        Errors:
  1339. ;            badComponentInstance    invalid scripting component instance
  1340. ;            errOSASystemError
  1341. ;            errAECoercionFail:        sourceData is not compilable
  1342. ;            errOSAScriptError:        sourceData was a bad script (syntax error)
  1343. ;            errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1344. ;                                    valid on input
  1345. ;            errOSAScriptError:        the executing script got an error
  1346. ;    
  1347. ;        ModeFlags:
  1348. ;            kOSAModeNeverInteract
  1349. ;            kOSAModeCanInteract
  1350. ;            kOSAModeAlwaysInteract
  1351. ;            kOSAModeCantSwitchLayer
  1352. ;            kOSAModeDontReconnect
  1353. ;            kOSAModeDoRecord
  1354. ;    
  1355.  
  1356. ;
  1357. ; pascal OSAError OSADoScript(ComponentInstance scriptingComponent, const AEDesc *sourceData, OSAID contextID, DescType desiredType, long modeFlags, AEDesc *resultingText)
  1358. ;
  1359.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1360.         Macro
  1361.         _OSADoScript
  1362.             move.l              #$00140603,-(sp)
  1363.             moveq               #0,D0
  1364.             dc.w                $A82A
  1365.         EndM
  1366.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1367.         IMPORT_CFM_FUNCTION OSADoScript
  1368.     ENDIF
  1369.  
  1370. ;        OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1371. ;        This routine is effectively equivalent to calling OSACompile followed by
  1372. ;        OSAExecute and then OSADisplay.  After execution, the compiled source
  1373. ;        and the resulting value are is disposed.  Only the resultingText
  1374. ;        descriptor is retained.  If a script error occur during processing, the 
  1375. ;        resultingText gets the error message of the error, and errOSAScriptError
  1376. ;        is returned.  OSAScriptError may still be used to extract more 
  1377. ;        information about the particular error.
  1378. ;    
  1379. ;        Errors:
  1380. ;            badComponentInstance    invalid scripting component instance
  1381. ;            errOSASystemError
  1382. ;            errAECoercionFail:        sourceData is not compilable or 
  1383. ;                                    desiredType not supported by scripting component
  1384. ;            errOSAScriptError:        sourceData was a bad script (syntax error)
  1385. ;            errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1386. ;                                    valid on input
  1387. ;            errOSAScriptError:        the executing script got an error
  1388. ;    
  1389. ;        ModeFlags:
  1390. ;            kOSAModeNeverInteract
  1391. ;            kOSAModeCanInteract
  1392. ;            kOSAModeAlwaysInteract
  1393. ;            kOSAModeCantSwitchLayer
  1394. ;            kOSAModeDontReconnect
  1395. ;            kOSAModeDoRecord
  1396. ;            kOSAModeDisplayForHumans
  1397. ;    
  1398.  
  1399. ; **************************************************************************
  1400. ;    OSA Optional Dialects Interface
  1401. ;**************************************************************************
  1402. ;    Scripting components that support the Dialects interface have the 
  1403. ;    kOSASupportsDialects bit set in it's ComponentDescription.
  1404. ;*************************************************************************
  1405.  
  1406. ;    These calls allows an scripting component that supports different dialects
  1407. ;    to dynamically switch between those dialects.  Although this interface is
  1408. ;    specified, the particular dialect codes are scripting component dependent.
  1409. ;
  1410.  
  1411. ;
  1412. ; pascal OSAError OSASetCurrentDialect(ComponentInstance scriptingComponent, short dialectCode)
  1413. ;
  1414.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1415.         Macro
  1416.         _OSASetCurrentDialect
  1417.             move.l              #$00020701,-(sp)
  1418.             moveq               #0,D0
  1419.             dc.w                $A82A
  1420.         EndM
  1421.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1422.         IMPORT_CFM_FUNCTION OSASetCurrentDialect
  1423.     ENDIF
  1424.  
  1425. ;        OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1426. ;    
  1427. ;        Errors:
  1428. ;            badComponentInstance    invalid scripting component instance
  1429. ;            errOSASystemError
  1430. ;            errOSANoSuchDialect:    invalid dialectCode
  1431. ;    
  1432.  
  1433. ;
  1434. ; pascal OSAError OSAGetCurrentDialect(ComponentInstance scriptingComponent, short *resultingDialectCode)
  1435. ;
  1436.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1437.         Macro
  1438.         _OSAGetCurrentDialect
  1439.             move.l              #$00040702,-(sp)
  1440.             moveq               #0,D0
  1441.             dc.w                $A82A
  1442.         EndM
  1443.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1444.         IMPORT_CFM_FUNCTION OSAGetCurrentDialect
  1445.     ENDIF
  1446.  
  1447. ;        OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1448. ;    
  1449. ;        Errors:
  1450. ;            badComponentInstance    invalid scripting component instance
  1451. ;            errOSASystemError
  1452. ;    
  1453.  
  1454. ;
  1455. ; pascal OSAError OSAAvailableDialects(ComponentInstance scriptingComponent, AEDesc *resultingDialectInfoList)
  1456. ;
  1457.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1458.         Macro
  1459.         _OSAAvailableDialects
  1460.             move.l              #$00040703,-(sp)
  1461.             moveq               #0,D0
  1462.             dc.w                $A82A
  1463.         EndM
  1464.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1465.         IMPORT_CFM_FUNCTION OSAAvailableDialects
  1466.     ENDIF
  1467.  
  1468. ;        OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1469. ;        This call return an AEList containing information about each of the
  1470. ;        currently available dialects of a scripting component.  Each item
  1471. ;        is an AERecord of typeOSADialectInfo that contains at least the fields
  1472. ;        keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1473. ;        keyOSADialectScriptCode.
  1474. ;    
  1475. ;        Errors:
  1476. ;            badComponentInstance    invalid scripting component instance
  1477. ;            errOSASystemError
  1478. ;    
  1479.  
  1480. ;
  1481. ; pascal OSAError OSAGetDialectInfo(ComponentInstance scriptingComponent, short dialectCode, OSType selector, AEDesc *resultingDialectInfo)
  1482. ;
  1483.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1484.         Macro
  1485.         _OSAGetDialectInfo
  1486.             move.l              #$000A0704,-(sp)
  1487.             moveq               #0,D0
  1488.             dc.w                $A82A
  1489.         EndM
  1490.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1491.         IMPORT_CFM_FUNCTION OSAGetDialectInfo
  1492.     ENDIF
  1493.  
  1494. ;        OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1495. ;        This call gives information about the specified dialect of a scripting
  1496. ;        component. It returns an AEDesc whose type depends on the selector 
  1497. ;        specified. Available selectors are the same as the field keys for a
  1498. ;        dialect info record. The type of AEDesc returned is the same as the 
  1499. ;        type of the field that has same key as the selector.
  1500. ;    
  1501. ;        Errors:
  1502. ;            badComponentInstance    invalid scripting component instance
  1503. ;            errOSASystemError
  1504. ;             errOSABadSelector
  1505. ;            errOSANoSuchDialect:    invalid dialectCode
  1506. ;    
  1507.  
  1508. ;
  1509. ; pascal OSAError OSAAvailableDialectCodeList(ComponentInstance scriptingComponent, AEDesc *resultingDialectCodeList)
  1510. ;
  1511.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1512.         Macro
  1513.         _OSAAvailableDialectCodeList
  1514.             move.l              #$00040705,-(sp)
  1515.             moveq               #0,D0
  1516.             dc.w                $A82A
  1517.         EndM
  1518.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1519.         IMPORT_CFM_FUNCTION OSAAvailableDialectCodeList
  1520.     ENDIF
  1521.  
  1522. ;        OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1523. ;        This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1524. ;        and  OSAGetDialectInfo to get information on dialects.
  1525. ;        This call return an AEList containing dialect code for each of the
  1526. ;        currently available dialects of a scripting component. Each dialect
  1527. ;        code is a short integer of type typeShortInteger.
  1528. ;    
  1529. ;        Errors:
  1530. ;            badComponentInstance    invalid scripting component instance
  1531. ;            errOSASystemError
  1532. ;
  1533. ;        Type of a dialect info record containing at least keyOSADialectName
  1534. ;        and keyOSADialectCode fields.
  1535. ;
  1536. ;        keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1537. ;
  1538. ;        Field of a typeOSADialectInfo record of typeChar.
  1539. ;        Field of a typeOSADialectInfo record of typeShortInteger.
  1540. ;        Field of a typeOSADialectInfo record of typeShortInteger.
  1541. ;        Field of a typeOSADialectInfo record of typeShortInteger.
  1542. ;    
  1543.  
  1544. ; **************************************************************************
  1545. ;    OSA Optional Event Handling Interface
  1546. ;**************************************************************************
  1547. ;    Scripting components that support the Event Handling interface have the 
  1548. ;    kOSASupportsEventHandling bit set in it's ComponentDescription.
  1549. ;*************************************************************************
  1550.  
  1551. ;
  1552. ; pascal OSAError OSASetResumeDispatchProc(ComponentInstance scriptingComponent, AEEventHandlerUPP resumeDispatchProc, long refCon)
  1553. ;
  1554.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1555.         Macro
  1556.         _OSASetResumeDispatchProc
  1557.             move.l              #$00080801,-(sp)
  1558.             moveq               #0,D0
  1559.             dc.w                $A82A
  1560.         EndM
  1561.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1562.         IMPORT_CFM_FUNCTION OSASetResumeDispatchProc
  1563.     ENDIF
  1564.  
  1565. ;        OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1566. ;        This function is used to set the ResumeDispatchProc that will be used
  1567. ;        by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1568. ;        found in the context, or the context event hander "continues" control
  1569. ;        onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1570. ;        may also be passed to this routine indicating that the handler registered
  1571. ;        in the application with AEInstallEventHandler should be used, or no
  1572. ;        dispatch should occur, respectively.
  1573. ;    
  1574. ;        Errors:
  1575. ;            badComponentInstance    invalid scripting component instance
  1576. ;            errOSASystemError
  1577. ;    
  1578.  
  1579.  
  1580. kOSAUseStandardDispatch            EQU        $FFFFFFFF
  1581. ;        Special ResumeDispatchProc constant which may be passed to 
  1582. ;        OSASetResumeDispatchProc indicating that the handler registered
  1583. ;        in the application with AEInstallEventHandler should be used.
  1584. ;        
  1585. ;        NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1586. ;                doesn't allow pointer types to be assigned to an enum.  All
  1587. ;                constants must be assigned as enums to translate properly to
  1588. ;                Pascal.
  1589. ;    
  1590.  
  1591.  
  1592. kOSANoDispatch                    EQU        0
  1593. ;        Special ResumeDispatchProc constant which may be passed to 
  1594. ;        OSASetResumeDispatchProc indicating that no dispatch should occur.
  1595. ;        
  1596. ;        NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1597. ;                doesn't allow pointer types to be assigned to an enum.  All
  1598. ;                constants must be assigned as enums to translate properly to
  1599. ;                Pascal.
  1600. ;    
  1601.  
  1602.  
  1603. kOSADontUsePhac                    EQU        $0001
  1604. ;        Special refCon constant that may be given to OSASetResumeDispatchProc
  1605. ;        only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1606. ;        This causes the standard dispatch to be performed, except the phac
  1607. ;        handler is not called.  This is useful during tinkerability, when
  1608. ;        the phac handler is used to lookup a context associated with an event's 
  1609. ;        direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1610. ;        bypass the phac handler would result in an infinite loop.
  1611. ;    
  1612.  
  1613. ;
  1614. ; pascal OSAError OSAGetResumeDispatchProc(ComponentInstance scriptingComponent, AEEventHandlerUPP *resumeDispatchProc, long *refCon)
  1615. ;
  1616.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1617.         Macro
  1618.         _OSAGetResumeDispatchProc
  1619.             move.l              #$00080802,-(sp)
  1620.             moveq               #0,D0
  1621.             dc.w                $A82A
  1622.         EndM
  1623.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1624.         IMPORT_CFM_FUNCTION OSAGetResumeDispatchProc
  1625.     ENDIF
  1626.  
  1627. ;        OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1628. ;        Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1629. ;        been registered, then kOSAUseStandardDispatch (the default) is returned.
  1630. ;    
  1631. ;        Errors:
  1632. ;            badComponentInstance    invalid scripting component instance
  1633. ;            errOSASystemError
  1634. ;    
  1635.  
  1636. ;
  1637. ; pascal OSAError OSAExecuteEvent(ComponentInstance scriptingComponent, const AppleEvent *theAppleEvent, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1638. ;
  1639.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1640.         Macro
  1641.         _OSAExecuteEvent
  1642.             move.l              #$00100803,-(sp)
  1643.             moveq               #0,D0
  1644.             dc.w                $A82A
  1645.         EndM
  1646.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1647.         IMPORT_CFM_FUNCTION OSAExecuteEvent
  1648.     ENDIF
  1649.  
  1650. ;        OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1651. ;        This call is similar to OSAExecute except the initial command to
  1652. ;        execute comes in the form of an AppleEvent.  If the contextID
  1653. ;        defines any event handlers for that event, they are used to process
  1654. ;        the event.  If no event handler can be found in the context
  1655. ;        errAEEventNotHandled is returned.  If an event handler is found and
  1656. ;        the hander "continues" control onward, the ResumeDispatchProc
  1657. ;        (registered with OSASetResumeDispatchProc, above) is called given the
  1658. ;        AppleEvent.  The result is returned as a scriptValueID.
  1659. ;    
  1660. ;        Errors:
  1661. ;            badComponentInstance    invalid scripting component instance
  1662. ;            errOSASystemError
  1663. ;            errOSAInvalidID
  1664. ;            errOSAScriptError:        the executing script got an error
  1665. ;            errAEEventNotHandled:    no handler for event in contextID
  1666. ;    
  1667. ;        ModeFlags:
  1668. ;            kOSAModeNeverInteract
  1669. ;            kOSAModeCanInteract
  1670. ;            kOSAModeAlwaysInteract
  1671. ;            kOSAModeCantSwitchLayer
  1672. ;            kOSAModeDontReconnect
  1673. ;            kOSAModeDoRecord
  1674. ;    
  1675.  
  1676. ;
  1677. ; pascal OSAError OSADoEvent(ComponentInstance scriptingComponent, const AppleEvent *theAppleEvent, OSAID contextID, long modeFlags, AppleEvent *reply)
  1678. ;
  1679.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1680.         Macro
  1681.         _OSADoEvent
  1682.             move.l              #$00100804,-(sp)
  1683.             moveq               #0,D0
  1684.             dc.w                $A82A
  1685.         EndM
  1686.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1687.         IMPORT_CFM_FUNCTION OSADoEvent
  1688.     ENDIF
  1689.  
  1690. ;        OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1691. ;        This call is similar to OSADoScript except the initial command to
  1692. ;        execute comes in the form of an AppleEvent, and the result is an 
  1693. ;        AppleEvent reply record.  If the contextID defines any event handlers
  1694. ;        for that event, they are used to process the event.  If no event handler
  1695. ;        can be found in the context errAEEventNotHandled is returned.  If an
  1696. ;        event handler is found and the hander "continues" control onward, the
  1697. ;        ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1698. ;        called given the AppleEvent.  The result is returned in the form of an
  1699. ;        AppleEvent reply descriptor. If at any time the script gets an error, or
  1700. ;        if the ResumeDispatchProc returns a reply event indicating an error,
  1701. ;        then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1702. ;        should never return errOSAScriptError).  Any error result returned by
  1703. ;        the ResumeDispatchProc will be returned by OSADoEvent.
  1704. ;    
  1705. ;        Errors:
  1706. ;            badComponentInstance    invalid scripting component instance
  1707. ;            errOSASystemError
  1708. ;            errOSAInvalidID
  1709. ;            errAEEventNotHandled:    no handler for event in contextID
  1710. ;    
  1711. ;        ModeFlags:
  1712. ;            kOSAModeNeverInteract
  1713. ;            kOSAModeCanInteract
  1714. ;            kOSAModeAlwaysInteract
  1715. ;            kOSAModeCantSwitchLayer
  1716. ;            kOSAModeDontReconnect
  1717. ;            kOSAModeDoRecord
  1718. ;    
  1719.  
  1720. ;
  1721. ; pascal OSAError OSAMakeContext(ComponentInstance scriptingComponent, const AEDesc *contextName, OSAID parentContext, OSAID *resultingContextID)
  1722. ;
  1723.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  1724.         Macro
  1725.         _OSAMakeContext
  1726.             move.l              #$000C0805,-(sp)
  1727.             moveq               #0,D0
  1728.             dc.w                $A82A
  1729.         EndM
  1730.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  1731.         IMPORT_CFM_FUNCTION OSAMakeContext
  1732.     ENDIF
  1733.  
  1734. ;        OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1735. ;        Makes a new empty context which may be passed to OSAExecute or 
  1736. ;        OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1737. ;        created. If parentContext is kOSANullScript then the resulting context
  1738. ;        does not inherit bindings from any other context.
  1739. ;    
  1740. ;        Errors:
  1741. ;            badComponentInstance    invalid scripting component instance
  1742. ;            errOSASystemError
  1743. ;            errOSAInvalidID
  1744. ;            errAECoercionFail:        contextName is invalid
  1745. ;    
  1746.  
  1747.  
  1748.     ENDIF ; __OSA__ 
  1749.  
  1750.